import mysql from 'mysql2/promise'
import { dbConfig } from './config/database'

// 创建数据库连接池
export const pool = mysql.createPool({
  host: dbConfig.host,
  user: dbConfig.user,
  password: dbConfig.password,
  database: dbConfig.database,
  waitForConnections: true,
  connectionLimit: 10,
  queueLimit: 0
})

// 测试连接
pool.getConnection()
  .then(connection => {
    console.log('数据库连接成功')
    connection.release()
  })
  .catch(err => {
    console.error('数据库连接失败:', err)
  }) 